package com.hjp.designmode.strategy.domain.impl;


import com.hjp.designmode.strategy.domain.Goods;

/**
 * @Description: 芒果
 * @Author: huangjp6
 * @Date: 2022/3/7 14:26
 */
public class Mango extends Goods {

    public Mango(MangoBuilder builder) {
        this.setOriginalPrice(builder.originalPrice);
        this.setCurrPrice(builder.currPrice);
        this.setWeight(builder.weight);
        this.setDiscount(builder.discount);
    }

    public Mango() {
        this(new MangoBuilder());
    }

    public static final class MangoBuilder {
        private double originalPrice;
        private double currPrice;
        private int weight;
        private double discount;

        private MangoBuilder() {
            originalPrice = 20.0;
            currPrice = 20.0;
            weight = 1;
            discount = 1.0;
        }

        public static MangoBuilder aMango() {
            return new MangoBuilder();
        }

        public MangoBuilder withOriginalPrice(double originalPrice) {
            this.originalPrice = originalPrice;
            return this;
        }

        public MangoBuilder withCurrPrice(double currPrice) {
            this.currPrice = currPrice;
            return this;
        }

        public MangoBuilder withWeight(int weight) {
            this.weight = weight;
            return this;
        }

        public MangoBuilder withDiscount(double discount) {
            this.discount = discount;
            return this;
        }

        public Mango build() {
            return new Mango(this);
        }
    }
}
